<template>
  <div class="page">
    <div class="page-title">碳配额管理单位</div>

    <div class="page-content">
      <div class="page-content-screen">
        <div class="screen">
          <vc-filter :menus="screen">
            <template #search>
              <search-input :width="175" v-model="searchTxt" placeholder="请输入企业名称"
                        @enter="handlerInput" @clear="handlerInput"/>
            </template>
            <div class="total">共计 <sapn style="color: rgba(255, 89, 89, 1)">&nbsp;{{ totalNum }}&nbsp;</sapn> 条</div>
          </vc-filter>
        </div>
      </div>
      <div class="page-content-table">
        <vc-table
          :loading="loading"
          :tableData="tableData"
          :columns="columns"
          :total="totalNum"
          :pageSize="PAGE_SIZE"
          :pageNum="queryData.pageNum"
          :defaultSort="{ field: 'noticeDate', order: 'desc' }"
          :maxHeight="maxHeight"
          @page-change="handleCurrentChange"
          @sort-change="sortChange"
        />
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import {getCarbonQuotaList} from '../apis';
import {useTable} from './useTable';
import {useScreen} from './useScreen';
import {calculateTableMaxHeight} from "@/utils";
import searchInput from '@/components/page-search/index.vue';
import { usePage } from '@/use/usePage';
const {PAGE_SIZE, screen, queryData} = useScreen();
let maxHeight = $ref(0)
queryData.type = 1;
const {data, loading, run} = useRequest(getCarbonQuotaList, {
  defaultParams: [{...queryData}],
  onSuccess: (data) => {
    tableData.value = data.values;
    totalNum.value = data.total;
    nextTick(() => {
      //计算最大高度
      maxHeight = calculateTableMaxHeight()
    })
  }
});
const { columns } = useTable();
const { tableData, totalNum, searchTxt, handlerInput, handleCurrentChange, sortChange } = usePage(queryData, run);

</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
